package com.bjsxt.livegoods.es.vo;

import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Objects;

/**
 * 临时值对象。只处理ES相关数据操作。
 * 是处理房屋租赁平台中搜索服务的数据对象。
 * 属性包括：主键、商品名、租赁方式、房屋简介、图片地址、价格、城市
 */
@Document(indexName="livegoods_product",type="product",
      shards = 2,replicas=0)
public class Product4Search implements Serializable {
    @Id
    private String id;
    @Field(name="title",type= FieldType.Text,analyzer = "ik_max_word")
    private String title;
    @Field(name="rentType",type=FieldType.Text,analyzer = "ik_smart")
    private String rentType;
    @Field(name="houseType",type=FieldType.Text,analyzer = "ik_smart")
    private String houseType;
    @Field(name="img",type=FieldType.Keyword)
    private String img;
    @Field(name="price",type=FieldType.Keyword)
    private String price;
    @Field(name="city",type=FieldType.Text,analyzer = "ik_smart")
    private String city;

    public Product4Search() {
    }

    public Product4Search(String id, String title, String rentType, String houseType, String img, String price, String city) {
        this.id = id;
        this.title = title;
        this.rentType = rentType;
        this.houseType = houseType;
        this.img = img;
        this.price = price;
        this.city = city;
    }

    @Override
    public String toString() {
        return "Product4Search{" +
                "id='" + id + '\'' +
                ", title='" + title + '\'' +
                ", rentType='" + rentType + '\'' +
                ", houseType='" + houseType + '\'' +
                ", img='" + img + '\'' +
                ", price='" + price + '\'' +
                ", city='" + city + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Product4Search that = (Product4Search) o;
        return Objects.equals(id, that.id) && Objects.equals(title, that.title) && Objects.equals(rentType, that.rentType) && Objects.equals(houseType, that.houseType) && Objects.equals(img, that.img) && Objects.equals(price, that.price) && Objects.equals(city, that.city);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, title, rentType, houseType, img, price, city);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getRentType() {
        return rentType;
    }

    public void setRentType(String rentType) {
        this.rentType = rentType;
    }

    public String getHouseType() {
        return houseType;
    }

    public void setHouseType(String houseType) {
        this.houseType = houseType;
    }

    public String getImg() {
        return img;
    }

    public void setImg(String img) {
        this.img = img;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }
}
